#!/bin/bash

set -xe

source $HOME/.bashrc

mkdir -p "$HOME/.vnc"
PASSWD_PATH="$HOME/.vnc/passwd"

echo "$VNC_PASSWD" | vncpasswd -f >> $PASSWD_PATH
chmod 600 $PASSWD_PATH

echo "CHROMIUM_FLAGS='--no-sandbox --disable-gpu --user-data-dir'" > $HOME/.chromium-browser.init

vncserver -kill $DISPLAY || rm -rfv /tmp/.X*-lock /tmp/.X11-unix
vncserver :1 -geometry $VNC_RESOLUTION -depth $VNC_COL_DEPTH && tail -F $HOME/.vnc/*$DISPLAY.log
